package dajiang;

/**
 * @author Hang
 * @date 2022/8/14
 * @project AutumnOffer
 * @description
 **/
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

class Solution {

    /* Write Code Here */
    public int longestWPI(int[] hours) {
        int[] res = new int[hours.length];
        int count = 0;
        if(hours[0] >= 8) count = 1;
        else count = -1;
        res[0] = 1;
        for(int i=1;i<hours.length;i++){
            if(hours[i] < 8&&count<2) {
                res[i] = 1;
            } else if(hours[i] < 8&&count>1) {
                res[i] = res[i-1] + 1;
                count--;
            }else if(hours[i] >= 8){
                res[i] = res[i-1]+1;
                count++;
            }
        }
        int max = 0;
        for(int i=0;i<res.length;i++){
            max = Math.max(max,res[i]);
        }
        return max;
    }
}

public class Main2 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int res;

        int hours_size = 0;
        hours_size = in.nextInt();
        int[] hours = new int[hours_size];
        for(int hours_i = 0; hours_i < hours_size; hours_i++) {
            hours[hours_i] = in.nextInt();
        }

        if(in.hasNextLine()) {
            in.nextLine();
        }

        res = new Solution().longestWPI(hours);
        System.out.println(String.valueOf(res));

    }
}

